//headers 
#include<algorithm>
#include<cassert>
#include<cstdio>
#include<deque>
#include<iostream>
#include<list>
#include<map>
#include<numeric>
#include<deque>
#include<set>
#include<string>
#include<sstream>
#include<stack>
#include<streambuf>
#include<vector>
using namespace std;

//macros
#define LET(x,a) typeof(a) x(a)
#define FOR(i,a,n) for(LET(i,a);i!=n;i++)
#define REP(i,n) FOR(i,0,n)
#define sz size()
#define pb push_back
#define ALL(x) x.begin(),x.end()
#define dbge(x) cout<<#x<<"->"<<x<<endl;
#define PRINT(x) { REP(_,x.sz) cout<<x[_]<<" "; cout<<endl; }
#define GI ({int _; scanf("%d",&_); _; })
#define VI vector<int>
#define VVI vector< vector<int> >
#define VS vector<string>
#define LL long long
#define INF (int)1e8

//code of suren
VVI mat;
VI dp[10][100];
int wgt[10][100];
int m,n;

int sum(VI a){
  int ret = 0; 
  REP(i,a.sz) ret+=[i];
  return ret;
}

VI find_path(int x , int y){
  if(dp[x][y].sz) return dp[x][y];
  VI ret;
  if(!y)  ret.pb(x); 
  else {
    VI p1,p2,p3;
    p1 = find_path(x,y-1);
    p2 = find_path((x-1)%m,y-1);
    p3 = find_path((x+1)%m,y-1);
    
    int max = sum
    
  }
}

int main(){

  while(cin>>m>>n){
    VVI _mat(m,VI(n,0)); mat=_mat;
    REP(i,m) REP(j,n) a[i][j]=GI;
    int ret = INF; VI path;
    REP(i,m) { path = find_path(i,n-1); ret = min(ret,sum(path)); }
    
  }
 
  return 0;

}
